<template>
  <div>
    <h2>News</h2>
    <button @click="toNewsItem('我要上天','001')">我要上天</button>
    <button @click="toNewsItem('我也要上天','002')">我也要上天</button>
    <button @click="toNewsItem('你们上吧 我不上','003')">你们上吧 我不上</button>
    <router-view></router-view>
  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  name: "News",
});

</script>

<script setup lang="ts">
import { useRouter } from "vue-router";
const router = useRouter();
// 路由导航
const toNewsItem = (title:string,id:string) => {
  router.push({
    name:"newsItem",
    query:{
      title,
      id
    }
  })
}
</script>

<style scoped>

</style>